<!--头部模板-->
{include file="public/header"/}

<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">
    <div class="layadmin-user-login-main">
        <div class="layadmin-user-login-box layadmin-user-login-header">
            <h2>小单中心 - 会员注册</h2>
            <p>© 2019 小单中心 ◇ 品质生活</p>
        </div>
        <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-cellphone" for="LAY-user-login-cellphone"></label>
                <input type="text" name="cellphone" id="LAY-user-login-cellphone" lay-verify="phone" placeholder="手机" class="layui-input">
            </div>
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-xs7">
                        <label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="LAY-user-login-vercode"></label>
                        <input type="text" name="vercode" id="code" lay-verify="required" placeholder="图形验证码" class="layui-input">
                    </div>
                    <div class="layui-col-xs5">
                        <div style="margin-left: 10px;">
                            <img src="{:url('user/Login/verify')}" style="width: 100%;height:100%;" alt="captcha" class="code_img" onclick='this.src=this.src+"?c="+Math.random()' />
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-xs7">
                        <label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="LAY-user-login-vercode"></label>
                        <input type="text" name="vercode" id="LAY-user-login-vercode" lay-verify="required" placeholder="短信验证码" class="layui-input">
                    </div>
                    <div class="layui-col-xs5">
                        <div style="margin-left: 10px;">
                            <button type="" class="layui-btn layui-btn-primary layui-btn-fluid" id="LAY-user-getsmscode" onclick="getCode()">短信验证码</button>
                        </div>
                    </div>
                </div>
            </div>
            <!--<div class="layui-form-item">-->
                <!--<input type="checkbox" name="agreement" lay-skin="primary" title="同意用户协议" checked>-->
            <!--</div>-->
            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-reg-submit" onclick="reg()">注 册</button>
            </div>
            <div class="layui-trans layui-form-item layadmin-user-login-other">
                <label>社交账号注册</label>
                <a href="javascript:;"><i class="layui-icon layui-icon-login-qq"></i></a>
                <a href="javascript:;"><i class="layui-icon layui-icon-login-wechat"></i></a>
                <a href="javascript:;"><i class="layui-icon layui-icon-login-weibo"></i></a>

                <a href="{:url('user/login/login')}" class="layadmin-user-jump-change layadmin-link layui-hide-xs">用已有帐号登入</a>
                <a href="{:url('user/login/login')}" class="layadmin-user-jump-change layadmin-link layui-hide-sm layui-show-xs-inline-block">登入</a>
            </div>
        </div>
    </div>

    <div class="layui-trans layadmin-user-login-footer">

        <p>© 2019 <a href="javascript:;" target="_blank">小单中心</a></p>
        <p>
            <span><a href="javascript:;" target="_blank">获取授权</a></span>
            <span><a href="javascript:;" target="_blank">在线演示</a></span>
            <span><a href="javascript:;" target="_blank">前往官网</a></span>
        </p>
    </div>

</div>

<script>

    //获取验证码
    function getCode(){
        var mobile = $("#LAY-user-login-cellphone").val();
        var code = $("#code").val();

        if(!mobile){
            return layer.msg('请输入手机号码');
        }
        if(!code){
            return layer.msg('请输入图形验证码');
        }

        $.ajax({
            type: "post",
            url: "{:url('user/Login/getCode')}",
            data: {
                'mobile': mobile,
                'code': code,
                'type':'reg',
            },
            dataType: "json",
            success: function(res) {
                if(res.code == 200){
                    layer.msg(res.msg, {icon: 1});
                }else{
                    layer.msg(res.msg, {icon: 5});
                }
            }
        });
    }

    //注册
    function reg(){
        var mobile = $("#LAY-user-login-cellphone").val();
        var msgCode = $("#LAY-user-login-vercode").val();

        if(!mobile){
            return layer.msg('请输入手机号码');
        }
        if(!msgCode){
            return layer.msg('请输入短信验证码');
        }

        $.ajax({
            type: "post",
            url: "{:url('user/Login/reg')}",
            data: {
                'mobile': mobile,
                'msgCode': msgCode,
            },
            dataType: "json",
            success: function(res) {
                if(res.code == 200){
                    layer.msg(res.msg, {icon: 1});
                }else{
                    layer.msg(res.msg, {icon: 5});
                }
            }
        });
    }

</script>

<!--底部模板-->
{include file="public/footer"/}